<template>
	<view>
		<u-divider>上传图片</u-divider>
		<u-upload :action="getUploadUrl" :file-list="fileList" :header="getUploadHeader" max-count="1"
				  :before-upload="beforeUpload"
				  @on-success="handleUploadSuccess">
		</u-upload>
	</view>
</template>

<script>
import mixin from "./mixin";

export default {
	mixins: [mixin],
	computed: {
		getUploadHeader() {
			let header = {}
			header['Authorization'] = this.vuex_token
			return header
		},
		getUploadUrl() {
			return `${this.$u.api.getBaseUrl()}/user/file/upload`
		}
	},
	data() {
		return {
			fileList: []
		}
	},
	methods: {
		beforeUpload(index, list) {
			uni.showLoading({
				title: '上传中...'
			})
		},
		handleUploadSuccess(res, index, lists, name) {
			this.component.src = res.data
			console.log(this.component.src)
			console.log('aa')
			this.handleUpdate(this.component)
			uni.hideLoading()
		}
	}
}
</script>

<style>
</style>
